package cn.nbt.busManage.dao.repository;

import cn.nbt.busManage.model.entity.Role;
import cn.nbt.busManage.model.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author lyq
 * @time 2024/6/16 21:27
 */

@Repository
public interface UserRepository extends JpaRepository<User, Integer> {

    @Query("SELECT r FROM User u JOIN u.roles r WHERE u.id = :id")
    List<Role> findRolesById(@Param("id") Integer id);
}
